package com.wang.consumer.config;


import com.rabbitmq.client.AMQP;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectConfiguration {

    /**
     * 创建交换机
     * @return
     */
    @Bean
    public Exchange directExchange() {
       return new DirectExchange("direct.exchange.new");
    }

    /**
     * 创建队列
     * @return
     */
    @Bean
    public Queue directQueue(){
        return new Queue("direct.queue.new",true);
    }


    /**
     * 创建队列
     * @return
     */
    @Bean
    public Queue objectQueue(){
        return new Queue("object.queue",true);
    }


    @Bean
    public Binding directBinding() {
        return BindingBuilder.bind(directQueue())
                .to(directExchange())
                .with("red").noargs(); // 如果你有一个自定义路由键
    }

}
